using System;
using System.Collections.Generic;
using System.Linq;
using DbUp.ScriptProviders;
using NSubstitute;
using NUnit.Framework;

namespace DbUp.Specification.Contexts
{
    public class GivenAnOutOfDateDatabase : EmptyDatabase
    {
        [SetUp]
        public override void BeforeEach()
        {
            base.BeforeEach();
            AllScripts = new List<SqlScript>() {
                new SqlScript("0001.southwind.sql", "--LITTLE BOBBY DROP TABLES WAS HERE.".ToSampleScript()),
                new SqlScript("0002.southwind.sql", "CREATE TABLE USERS --AGAIN".ToSampleScript())
            };

            var appliedScript = AllScripts.First();
            ScriptProvider.GetScripts().Returns(AllScripts);
            VersionTracker.GetExecutedScripts().Returns(new List<SqlScriptAlreadyApplied>
            {
                new SqlScriptAlreadyApplied(
                    appliedScript.VersionKey,
                    "0001.southwind.sql", "",
                    DateTime.Now, "")
            });
        }
    }
}

